/// @tags:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

namespace BlueQuantum {

typedef long long LL;

int constexpr N = 1e5 + 5, MOD = 1e9 + 7, ST = 18;

int n;
int st[N][ST], lg[N];
int a[N], b[N], ans[N];
LL d[N];

inline int query(int l, int r, int *const a) {
  int k = lg[r - l + 1];
  if (a[st[l][k]] > a[st[r - (1 << k) + 1][k]]) return st[l][k];
  return st[r - (1 << k) + 1][k];
}

inline int add(int a, int b) {
  a += b;
  return a >= MOD ? a - MOD : a;
}

inline int dec(int a, int b) {
  a -= b;
  return a < 0 ? a + MOD : a;
}

void solve(int l, int r, int *const a) {
  if (l > r) return;
  int pos = query(l, r, a), L1 = pos - l + 1, L2 = r - pos + 1;
  if (L1 > L2) swap(L1, L2);
  d[1] = add(d[1], a[pos]);
  d[L1 + 1] = dec(d[L1 + 1], a[pos]);
  d[L2 + 1] = dec(d[L2 + 1], a[pos]);
  d[r - l + 3] = add(d[r - l + 3], a[pos]);
  solve(l, pos - 1, a);
  solve(pos + 1, r, a);
}

void solve(int *const a) {
  memset(d, 0, sizeof(d));
  for (int i = 1; i <= n; ++i) st[i][0] = i;
  for (int j = 1; j < ST; ++j)
    for (int i = 1; i <= n; ++i) {
      if (i + (1 << (j - 1)) <= n) {
        if (a[st[i][j - 1]] > a[st[i + (1 << (j - 1))][j - 1]])
          st[i][j] = st[i][j - 1];
        else
          st[i][j] = st[i + (1 << (j - 1))][j - 1];
      } else
        st[i][j] = st[i][j - 1];
    }
  solve(1, n, a);
  for (int i = 1; i <= n; ++i) d[i] = (d[i] + d[i - 1]) % MOD;
  for (int i = 1; i <= n; ++i) d[i] = (d[i] + d[i - 1]) % MOD;
  for (int i = 1; i <= n; ++i) ans[i] = (LL)ans[i] * d[i] % MOD;
}

inline int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], a[i] += i;
  for (int i = 1; i <= n; ++i) cin >> b[i], b[i] += i;
  for (int i = 1; i <= n; ++i) ans[i] = 1;
  lg[1] = 0;
  for (int i = 2; i <= n; ++i) lg[i] = lg[i / 2] + 1;
  solve(a);
  solve(b);
  for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("sum.in", "r", stdin);
  freopen("sum.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
